package com.dzx.design.behavioral.iterator;

/**
 * @author dzx
 * @ClassName:
 * @Description: 迭代器模式
 * @date 2019年08月09日 14:28:58
 */
public class Test {


    public static void main(String[] args) {
        CourseAggregate courseAggregate = new CourseAggregateImpl();
        courseAggregate.addCourse(new Course("数学"));
        courseAggregate.addCourse(new Course("英语"));

        CourseIterator courseIterator = courseAggregate.getCourseIterator();

        while (!courseIterator.isLastCourse()) {
            Course course = courseIterator.nextCourse();
            System.out.println(course);
        }
    }

}
